<template>
  <div>
    <navigate>查看测评结果</navigate>
    <div class="det_cont">
      <!-- tab切换 -->
      <div class="tab_list dis_flex white_box">
        <div
          class="item_tab"
          v-for="(item, index) in tabArr"
          :key="index"
          @click="chooseTab(index)"
          :class="currentTab == index ? 'active_tab' : ''"
        >
          {{ item }}
        </div>
      </div>

      <!-- 查看测评结果 -->
      <look-done-result
        v-show="currentTab == 0"
        :info="info"
        :type="5"
      ></look-done-result>
      <!-- 查看答题情况 -->
      <look-done-statuation
        v-show="currentTab == 1"
        ref="lookDoneStatuation"
        :questionList="questionList"
        :ratingScaleName="info.rating_scale_name"
        :type="5"
      ></look-done-statuation>
    </div>
  </div>
</template>

<script>
import lookDoneResult from "@/views/core/lookDoneResult.vue";
import lookDoneStatuation from "@/views/core/lookDoneStatuation.vue";
import {
  queryGroupActivityResult,
  queryAnswerSituation,
} from "@/api/funcation/groupActivity";
export default {
  data() {
    return {
      tabArr: ["查看测评结果", "查看答题情况"],
      currentTab: 0,
      resultId: "",
      info: {},
      questionList: [],
    };
  },
  components: {
    "look-done-result": lookDoneResult,
    "look-done-statuation": lookDoneStatuation,
  },
  created() {
    this.resultId = this.$route.query.resultId;
    this.getGroupActivityResult();
  },
  methods: {
    //答题问题
    async getAnswerSituation() {
      let res = await queryAnswerSituation({ id: this.resultId });
      if (res.code == 200) {
        this.questionList = res.data.QuestionList;
      }
    },
    async getGroupActivityResult() {
      let res = await queryGroupActivityResult({ id: this.resultId });
      if (res.code == 200) {
        this.info = res.data;
      }
    },
    chooseTab(v) {
      this.currentTab = v;
      if (this.currentTab == 0) {
        this.getGroupActivityResult();
      } else {
        this.getAnswerSituation();
      }
    },
  },
};
</script>

<style lang="less" scoped>
.tab_list {
  height: 46.67px;
  line-height: 40px;
  margin-bottom: 10px;
  margin: 10px 10px 0 10px;
}

.item_tab {
  flex: 1;
  height: 40px;
  text-align: center;
  font-weight: bold;
  font-size: 14.67px;
}

.active_tab {
  border-radius: 6.67px;
  color: #ffffff;
  background: linear-gradient(0deg, #ffffff -20%, rgba(255, 255, 255, 0) 20%),
    #00aeff;
}
</style>
